package servlet;

import service.UserService;

import java.io.IOException;
import java.io.PrintWriter;
import jakarta.servlet.*;
import jakarta.servlet.http.*;
import jakarta.servlet.annotation.WebServlet;;

@WebServlet("/MainServlet")
public class MainServlet extends ServletBase {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) 
                          throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");

        HttpSession session = request.getSession(false);
        if (session != null) {
            session.removeAttribute("username");
            session.removeAttribute("user_acccess_time");
        }
        request.setAttribute("msg", "You have logged out.");
        request.getRequestDispatcher("/web/login.jsp").include(request, response);
    }
}
